package com.braincookie.plugins.jira.config.servlet;


import static com.atlassian.jira.template.TemplateSources.file;

import com.atlassian.jira.template.VelocityTemplatingEngine;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
 
public class FilterTabConfigServlet extends HttpServlet {
    private static final Logger log = LoggerFactory.getLogger(FilterTabConfigServlet.class);
    private static final String TEMPLATE_PATH = "/templates/config/configservlet.vm";  // new!
 
    private final VelocityTemplatingEngine templateRenderer;  // new!
 
    // new!
    public FilterTabConfigServlet(VelocityTemplatingEngine templateRenderer) {
        this.templateRenderer = templateRenderer;
    }
 
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        Map<String, Object> context = Maps.newHashMap();  // new!
 
        resp.setContentType("text/html;charset=utf-8");  // modified!
        resp.getWriter().write(templateRenderer.render(file(TEMPLATE_PATH)).asHtml());
    }
}